<template>
  <div>
    <!--  头部  -->
    <header>
      <div>
        <div class="nav-left">
          <!--    logo    -->
          <div class="brand">
            <router-link to="/">
              <img src="../assets/images/logo.png" alt="logo" />
            </router-link>
          </div>
          <el-divider direction="vertical"></el-divider>
          <h4>草稿</h4>
        </div>
        <div class="nav-right">
          <div>
            <el-button
              class="btn-writing"
              plain
              type="mini"
              icon="el-icon-edit"
            >
              写文章
            </el-button>
          </div>
          <div>
            <i class="el-icon-more"></i>
          </div>
        </div>
      </div>
    </header>
    <section>
      <div class="content">
        <div v-for="(item, index) in item" :key="index">
          <h3>{{ item.title }}</h3>
          <div>
            <el-tooltip
              class="item"
              effect="dark"
              :content="item.time"
              placement="bottom"
            >
              <span style="cursor: pointer"> {{ item.time_age }}前 · </span>
            </el-tooltip>
            <span>共 {{ item.num }} 字</span> ·
            <span @click="deleteDraft(index)" class="delete">删除</span>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
export default {
  name: "draft",
  data() {
    return {
      item: [
        {
          title: "无标题",
          time_age: "28分钟",
          time: "2019-09-03 09:01:22",
          num: 4
        },
        {
          title: "无标题",
          time_age: "12分钟",
          time: "2019-09-03 09:01:22",
          num: 4
        }
      ]
    };
  },
  created() {},
  methods: {
    deleteDraft(index) {
      this.$confirm("删除后无法恢复，是否确定要删除这篇草稿？", "删除草稿", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        showClose: false, //去掉关闭按钮
        closeOnClickModal: false, //关闭点击蒙层关闭
        cancelButtonClass: "cancelDraft", //取消类名
        confirmButtonClass: "enterDraft", //确定按钮
        lockScroll: false, //滚动
        center: true //居中
      })
        .then(() => {
          this.$message({
            type: "success",
            customClass: "z-index-tip",
            message: "删除成功!",
            duration: 2000
          });
          console.log("删除", index);
        })
        .catch(() => {
          console.log("取消");
        });
    }
  }
};
</script>

<style scoped lang="less">
/*头部*/
header {
  z-index: 9999;
  position: fixed;
  top: 0;
  width: 100%;
  padding: 10px 0;
  background-color: #fff;
  box-shadow: 0 2px 2px 0 rgba(237, 237, 237, 0.4);
  & > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 1000px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
    .nav-left {
      display: flex;
      align-items: center;
      /deep/.el-divider--vertical {
        height: 2rem;
        margin: 0 15px;
      }
      .brand {
        width: 80px;
        img {
          width: 100%;
          height: 100%;
        }
      }
      & > span {
        margin-left: 30px;
        font-size: 14px;
        color: #95998f;
      }
    }
    .nav-right {
      display: flex;
      align-items: center;
      color: #95998f;
      .btn-writing {
        margin-right: 20px;
        color: #6b9147;
        border-color: #6b9147;
      }
    }
  }
}
section {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  padding-top: 40px;
  margin-top: 55px;
  .content {
    width: 700px;
    margin: 30px auto;
    & > div {
      padding: 10px 0;
      border-bottom: 1px solid #ccc;
      & > h3 {
        margin: 10px 0;
        color: #333;
      }
      & > div {
        font-size: 14px;
        color: #666;
        .delete {
          cursor: pointer;
          &:hover {
            color: #999;
          }
        }
      }
    }
  }
}
</style>
